/**
 * Project Name:xiaocao-java-basic
 * File Name:CollectionEnhancement.java
 * Package Name:top.wanzc.java.basic.jdk9.to17.feature
 * Date:2024年2月10日上午11:25:49
 * Copyright (c) 2024, zhengchong.wan@minicore.com.hk All Rights Reserved.
 *
*/

package top.wanzc.java.basic.jdk9.to17.feature;

import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * @className:CollectionEnhancement 
 * @comment: 注释信息 
 * @date:     2024年2月10日 上午11:25:49 
 * @author   zhengchong.wan
 * @since    V1.0.0	 
 */
public class CollectionEnhancement {

	public static void main(String[] args) {
		// 使用of创建不可变集合
		List<Integer> list = List.of(1, 2, 3);
		System.out.println(list);
		// 添加元素会报错
		//list.add(4);
		Set<Integer> set = Set.of(1, 2, 3, 4, 5);
		
		Map<Integer, String> map1 = Map.of(1, "v1", 2, "v2");
		Map<Integer, String> map2 = Map.ofEntries(
			    Map.entry(1, "v1"),
			    Map.entry(2, "v2"),
			    Map.entry(3, "v3"),
			    Map.entry(4, "v4")
			);
		List<String> sampleList = Arrays.asList("felord.cn", "java 11");
		String[] array = sampleList.toArray(String[]::new);
		System.out.println(Arrays.toString(array));
	}

}

